package com.xuxu.blog.dao;

import com.xuxu.blog.entity.PermissonEntity;
import com.xuxu.blog.entity.UserEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.HashSet;
import java.util.List;

/**
 * 
 * 
 * @author maxuxu
 * @email maxuxu019@gmail.com
 * @date 2022-08-21 22:22:31
 */
@Mapper
public interface UserDao extends BaseMapper<UserEntity> {
    @Select(value = "select p.* from user u, role_permission rp,permisson p where u.role = rp.role_id and rp.permission_id = p.id and u.username =#{username}")
    HashSet<PermissonEntity> selectPermissions(String username);

    @Update("update user set points=points+ #{points} where id=#{id}")
    int updatePoint(@Param("points") Integer points, @Param("id") int id);
}
